import java.util.Scanner;

public class T5 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += i % 9 == 0 ? 9 : i % 9;
        }
        System.out.println(sum);
    }
}
